﻿using System;
using System.Runtime.InteropServices.ComTypes;
using System.Threading;
using Newtonsoft.Json;
using Nl.Mq.Domain;
using Nl.RabbitMq.Demo.EasyNetQWrapper;

namespace Nl.RabbitMq.Demo.MessagePublisher
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            RabbitMqClient client=new RabbitMqClient(@"host=localhost");

            for (int i = 0; i < 4; i++)
            {
                Thread thread=new Thread(() =>
                {
                    var j = 0;
                    while (j<5)
                    {
                        client.PublishWithTopic(new TestAckMessage() { msg = "MessagePublisher" + Guid.NewGuid() }, "A.Test*");
                        //client.Publish<MqExcepotionMessage>(new MqExcepotionMessage(JsonConvert.SerializeObject(new TestAckMessage() { msg = "error" + Guid.NewGuid() }), null));
                        Thread.Sleep(1000);
                        j = j + 1;
                    }
                });
                thread.Start();
            }



            Console.Read();
          
        }
    }

}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               